package Help.Manager.Album;
import java.util.ArrayList;

import photos.core.commons.TouchImageView;


import com.example.easynote.R;

import android.app.Activity;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

/*
 * FullScreenImageAdapter.
 */
public class FullScreenImageAdapter extends PagerAdapter {

	private Activity activity;
	private ArrayList<String> imagesPath;
	private LayoutInflater inflater;

	public FullScreenImageAdapter(Activity activity,
			ArrayList<String> imagePaths) {
		this.activity = activity;
		this.imagesPath = imagePaths;
		this.inflater = LayoutInflater.from(this.activity);
	}

	@Override
    public Object instantiateItem(ViewGroup container, int position) {
        TouchImageView imgDisplay;
 
        View viewLayout = inflater.inflate(R.layout.fullscreen_image, container,
                false);
 
        imgDisplay = (TouchImageView) viewLayout.findViewById(R.id.touchImg);

        BitmapHelpers.loadBitmap(imagesPath.get(position), 
        		imgDisplay
        		,LayoutHelpers.getDeviceWidth(activity)
        		,0);

        ((ViewPager) container).addView(viewLayout);
 
        return viewLayout;
	}
	
	@Override
	public int getCount() {
		return this.imagesPath.size();
	}

	@Override
    public boolean isViewFromObject(View view, Object object) {
        return view == ((RelativeLayout) object);
    }
	
	@Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        ((ViewPager) container).removeView((RelativeLayout) object);

    }

}
